<?php
/**
 * This is users/admin_properties template file. 
 *
 * @copyright     Copyright 2008-2010, LilCake.net
 * @link          http://lilcake.net LilCake.net
 * @package       lil
 * @subpackage    lil.views.users
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
	$user_properties = array(
		'title_for_layout' => __d('lil', 'User Properties'),
		'form' => array(
			'pre' => '<div class="form">',
			'post' => '</div>',
			'lines' => array(
				'form_start' => array(
					'class' => $this->LilForm,
					'method' => 'create',
					'parameters' => array('model' => 'User')
				),
				'id' => array(
					'class' => $this->LilForm,
					'method' => 'hidden',
					'parameters' => array('field' => 'id')
				),
				'referer' => array(
					'class' => $this->LilForm,
					'method' => 'hidden',
					'parameters' => array('field' => 'referer')
				),
				'fs_basics_start' => '<fieldset>',
				'lg_basics' => sprintf('<legend>%s</legend>', __d('lil', 'Basics')),
				'name' => array(
					'class' => $this->LilForm,
					'method' => 'input',
					'parameters' => array(
						'field' => Configure::read('Lil.userDisplayField'),
						'options' => array(
							'label' => __d('lil', 'Name') . ':',
							'error' => __d('lil', 'User\'s name is required.'),
							'class' => 'big'
						)
					)
				),
				'fs_basics_end' => '</fieldset>',
				'passwords' => array(
					'class' => $this->LilForm,
					'method' => 'inputs',
					'parameters' => array(
						'inputs' => array(
							'legend' => __d('lil', 'Change password'),
							'old_pass' => array(
								'type'    => 'password',
								'label'   => __d('lil', 'Old password') . ':',
								'error'   => __d('lil', 'Invalid old password.'),
								'default' => ''
							),
							'passwd' => array(
								'type'    => 'password',
								'label' => __d('lil', 'New password') . ':',
								'error' => __d('lil', 'Password is required, format must be valid.'),
							),
							'repeat_pass' => array(
								'type'    => 'password',
								'label'   => __d('lil', 'Repeat password') . ':',
								'error'   => __d('lil', 'Passwords do not match.'),
								'default' => ''
							),
						)
					)
				),
				'submit' => array(
					'class' => $this->LilForm,
					'method' => 'submit',
					'parameters' => array(
						'label' => __d('lil', 'Save')
					)
				),
				'form_end' => array(
					'class' => $this->LilForm,
					'method' => 'end',
					'parameters' => array()
				),
			)
		)
	);
	
	App::uses('LilPluginRegistry', 'Lil.Lil'); $registry = LilPluginRegistry::getInstance();
	$user_properties = $registry->callPluginHandlers($this, 'form_edit_user', $user_properties);
	
	$this->set('title_for_layout', $user_properties['title_for_layout']);
	
	// form display begins
	echo $user_properties['form']['pre']; 
	foreach ($user_properties['form']['lines'] as $name => $line) {
		if (is_string($line)) {
			echo $line;
		} else if (!empty($line['class'])) {
			$parameters = array();
			if (!empty($line['parameters'])) {
				$parameters = (array)$line['parameters'];
			}
			if (is_object($line['class'])) {
				$use_object =& $line['class'];
			} else {
				$use_object =& ${$line['class']};
			}
			echo call_user_func_array(array($use_object, $line['method']), $parameters);
		}
	}
	echo $user_properties['form']['post'];